package com.cloud.workTest;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.BeanUtils;

import java.util.Map;

public class JSONObjectTest {
    static class ThirdDoctScienceQuery {
        /**
         * 医院id
         */
        private String corpId;

        /**
         * 医联体id
         */
        private String unionId;

        /**
         * 科室编号
         */
        private String deptCode;

        /**
         * 科室名称
         */
        private String deptName;

        /**
         * 医生编号
         */
        private String doctCode;

        /**
         * 医生姓名
         */
        private String doctName;

        public String getCorpId() {
            return corpId;
        }

        public void setCorpId(String corpId) {
            this.corpId = corpId;
        }

        public String getUnionId() {
            return unionId;
        }

        public void setUnionId(String unionId) {
            this.unionId = unionId;
        }

        public String getDeptCode() {
            return deptCode;
        }

        public void setDeptCode(String deptCode) {
            this.deptCode = deptCode;
        }

        public String getDeptName() {
            return deptName;
        }

        public void setDeptName(String deptName) {
            this.deptName = deptName;
        }

        public String getDoctCode() {
            return doctCode;
        }

        public void setDoctCode(String doctCode) {
            this.doctCode = doctCode;
        }

        public String getDoctName() {
            return doctName;
        }

        public void setDoctName(String doctName) {
            this.doctName = doctName;
        }

        @Override
        public String toString() {
            return "ThirdDoctScienceQuery{" +
                    "corpId='" + corpId + '\'' +
                    ", unionId='" + unionId + '\'' +
                    ", deptCode='" + deptCode + '\'' +
                    ", deptName='" + deptName + '\'' +
                    ", doctCode='" + doctCode + '\'' +
                    ", doctName='" + doctName + '\'' +
                    '}';
        }
    }

    static class DoctScienceQuery {

        /**
         * 医院id
         */
        private Long corpId;

        /**
         * 医联体id
         */
        private Long unionId;

        /**
         * 科室编号
         */
        private String deptCode;

        /**
         * 科室名称
         */
        private String deptName;

        /**
         * 医生编号
         */
        private String doctCode;

        /**
         * 医生姓名
         */
        private String doctName;

        public Long getCorpId() {
            return corpId;
        }

        public void setCorpId(Long corpId) {
            this.corpId = corpId;
        }

        public Long getUnionId() {
            return unionId;
        }

        public void setUnionId(Long unionId) {
            this.unionId = unionId;
        }

        public String getDeptCode() {
            return deptCode;
        }

        public void setDeptCode(String deptCode) {
            this.deptCode = deptCode;
        }

        public String getDeptName() {
            return deptName;
        }

        public void setDeptName(String deptName) {
            this.deptName = deptName;
        }

        public String getDoctCode() {
            return doctCode;
        }

        public void setDoctCode(String doctCode) {
            this.doctCode = doctCode;
        }

        public String getDoctName() {
            return doctName;
        }

        public void setDoctName(String doctName) {
            this.doctName = doctName;
        }
    }

    //这个例子表明，只有类型相同才能拷贝成功
    public static void testCopyProperties() {
        DoctScienceQuery doctScienceQuery = new DoctScienceQuery();
        doctScienceQuery.setCorpId(270l);
        doctScienceQuery.setUnionId(29l);
        doctScienceQuery.setDoctCode("001820");
        ThirdDoctScienceQuery thirdDoctScienceQuery = new ThirdDoctScienceQuery();
        BeanUtils.copyProperties(doctScienceQuery,thirdDoctScienceQuery);
        System.out.println(thirdDoctScienceQuery);

    }

    public static void main(String[] args) {
        ThirdDoctScienceQuery thirdDoctScienceQuery = new ThirdDoctScienceQuery();
        thirdDoctScienceQuery.setCorpId("3702010328");
        thirdDoctScienceQuery.setDoctCode("001820");
        thirdDoctScienceQuery.setUnionId("29");
        Map<String, String> param = (Map) JSONObject.parseObject(JSONObject.toJSONString(thirdDoctScienceQuery));
        System.out.println(param);

        testCopyProperties();

    }

}
